<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%
	String type = request.getParameter("type");
	if (type == null) {
		type = "";
	}

	String user_id = request.getParameter("user_id");
	if (user_id == null) {
		user_id = "";
	}

	String param3_in1 = request.getParameter("param3[in_param1]");
	if (param3_in1 == null) {
		param3_in1 = "";
	}
	String param3_in2 = request.getParameter("param3[in_param2]");
	if (param3_in2 == null) {
		param3_in2 = "";
	}

	StringBuilder value = new StringBuilder(128);
	if (type.equals("1")){//RAW
		value.append("返回RAW字符串，type = ");
		value.append(type);
		value.append("; user_id = ");
		value.append(user_id);
		value.append("; param3[in_param1] = ");
		value.append(param3_in1);
		value.append("; param3[in_param2] = ");
		value.append(param3_in2);
		out.println(value);
	}
	else if (type.equals("2")){//JSON
		value.append("{\"type\": ");
		value.append(type);
		value.append(", \"user_id\": ");
		value.append(user_id);
		value.append(", \"message\": \"返回了JSON对象\"");
		value.append(", \"xnml_user\": \"你好，这是你的个人主页： <xn:profile-pic uid=\\\"loggedinuser\\\" linked=\\\"true\\\"/>\"");
		value.append("}");
		out.println(value);
	}
	else if (type.equals("3")){//XNML
		value.append("返回XNML片段，type = ");
		value.append(type);
		value.append("; param3[in_param1] = ");
		value.append(param3_in1);
		value.append("; param3[in_param2] = ");
		value.append(param3_in2);
		value.append("；你好，<xn:name uid=\"");
		value.append(user_id);
		value.append("\" linked=\"true\"/>");
		out.println(value);
	}
	else {//Unknown type
		out.println("Unknown type detected!");
	}
%>
